using System.Collections.Generic;
using System.Windows.Forms;
using Core;
using DoItNow.UI;

namespace DoItNow.Features
{
	public abstract class IncrementalSearchFeature : BindableCommandFeature
	{
		protected IncrementalSearchFeature(string name, string binding, Ide ide, OutputPane outputPane)
			: base(name, binding, ide, outputPane)
		{
		}

		public override void OnExecute()
		{
			var form = new IncrementalSearchForm(Name + ":", CreateSearchEntries());

			if (form.ShowDialog(Ide.MainWindow) == DialogResult.OK)
				OnSearchSucceeded(form.SearchResult.Tag);
		}

		public abstract List<SearchEntry> CreateSearchEntries();
		public abstract void OnSearchSucceeded(object tag);
	}
}